package com.longbig.service;

/**
 * @author: yyl
 * @date: 2025/4/9:16:41
 */
// LeaveService.java
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LeaveService {

    @Autowired
    private RuntimeService runtimeService;

    @Autowired
    private TaskService taskService;

    public void startProcess(String processDefinitionId, String employee, String manager) {
        Map<String, Object> variables = new HashMap<>();
        variables.put("employee", employee);
        variables.put("manager", manager);
        runtimeService.startProcessInstanceById(processDefinitionId, variables);
    }

    public List<Task> getTasks(String assignee) {
        return taskService.createTaskQuery()
                .taskAssignee(assignee)
                .list();
    }

    public void completeTask(String taskId) {
        taskService.complete(taskId);
    }
}
